package com.mall.controller;

import com.mall.domain.ItemCat;
import com.mall.domain.Menus;
import com.mall.service.IItemCatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 商品类别web层
 * @author : Bei-Zhen
 * @date : 2021-01-04 16:57
 */
@Controller
public class ItemCatController {

    @Autowired
    private IItemCatService iItemCatService;

    /**
     * 渲染商品类别菜单
     * @param
     * @return
     */
    @RequestMapping("/categories")
    public  @ResponseBody
    Map<String,Object> getCategories() {
        Map<String,Object> categoriesMap = new HashMap<>();
        //获取商品类别集合
        List<ItemCat> categories = iItemCatService.getTree();
        //放入Map集合
        categoriesMap.put("message",categories);

        //创建状态Map
        Map<String,Object> metaMap = new HashMap<>();
        metaMap.put("msg","获取商品类别列表成功");
        metaMap.put("status",200);

        categoriesMap.put("meta",metaMap);
        return categoriesMap;
    }
}
